package com.immediatus.engine.modifier;


import com.immediatus.engine.contracts.Interpolator;

public abstract class BaseDoubleValueChangeModifier<T> extends BaseSingleValueChangeModifier<T> {
	private float _valueB;

	public BaseDoubleValueChangeModifier(final float duration_, final float valueA_, final float valueB_) {
		super(duration_, valueA_);
        _valueB = valueB_;
	}

    public BaseDoubleValueChangeModifier(final float duration_, final float valueA_, final float valueB_, Interpolator interpolator_) {
        super(duration_, valueA_, interpolator_);
        _valueB = valueB_;
    }

	public BaseDoubleValueChangeModifier(final float duration_, final float valueA_, final float valueB_, final IModifierListener<T> listener_) {
		super(duration_, valueA_, listener_);
		this._valueB = valueB_;
	}

    public BaseDoubleValueChangeModifier(final float duration_, final float valueA_, final float valueB_, final IModifierListener<T> listener_, Interpolator interpolator_) {
        super(duration_, valueA_, listener_, interpolator_);
        this._valueB = valueB_;
    }

	protected BaseDoubleValueChangeModifier(final BaseDoubleValueChangeModifier<T> doubleValueChangeModifier_) {
		super(doubleValueChangeModifier_);
        this._valueB = doubleValueChangeModifier_._valueB;

	}

	@Override
	protected void onChangeValue(final T item_, final float secondsElapsed_, final float valueA_) {
        final float interpolation = getInterpolator().interpolate(secondsElapsed_ / getDuration());
        this.onChangeValues(item_, secondsElapsed_, valueA_, this._valueB * interpolation);
	}

	protected abstract void onChangeValues(T item_, float secondsElapsed_, float valueA_, float valueB_);
}
